from odoo import fields, models, api, Command, _
from odoo.exceptions import UserError
from odoo.tools.float_utils import float_compare, float_is_zero


class SupplementRatioConfig(models.Model):
    _name = 's.supplement.ratio.config'
    _description = 'supplement ratio config'

    name = fields.Char(string='Name', default='补投比例')
    ratio = fields.Float(string='Ratio(%)')
    line_ids = fields.One2many('s.supplement.ratio.line', 'config_id', string='Ratio Lines')


class SupplementRatioLine(models.Model):
    _name = 's.supplement.ratio.line'
    _description = 'supplement ratio line'

    config_id = fields.Many2one('s.supplement.ratio.config', string='Ratio Config')
    categ_ids = fields.Many2many('product.category', string='Product Category')
    ratio = fields.Float(string='Ratio(%)')
